import baiduConfig from '../../../../api/config/channel/baiduBCP-config'
import * as globalTypes from '../../../../mutation-types'

/**
 * 保存百度BCP对接参数
 * @param data
 */
export const saveBaiduOcpcConfig = ({commit, state, rootState, dispatch}, data) => {
  return baiduConfig.saveBaiduOcpcConfig(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
/**
 * 查询百度BCP对接列表
 * @param data
 */
export const getBaiduOcpcConfigs = ({commit, state, rootState, dispatch}, data) => {
  return baiduConfig.getBaiduOcpcConfigs(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
/**
 * 更新百度BCP对接列表
 * @param data
 */
export const updateBaiduOcpcConfig = ({commit, state, rootState, dispatch}, data) => {
  return baiduConfig.updateBaiduOcpcConfig(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
/**
 * 删除百度BCP对接
 * @param data
 */
export const removeBaiduOcpcConfig = ({commit, state, rootState, dispatch}, data) => {
  return baiduConfig.removeBaiduOcpcConfig(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
/**
 * 创建默认接待流程
 * @param data
 */
export const saveOcpcTemplateConfig = ({commit, state, rootState, dispatch}, data) => {
  return baiduConfig.saveOcpcTemplateConfig(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
